package com.ruoyi.zdgz.controller;

import java.util.List;

import com.ruoyi.zdgz.domain.Psjc;
import com.ruoyi.zdgz.service.IPsjcService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 主排水测点基础数据Controller
 * 
 * @author ruoyi
 * @date 2021-06-21
 */
@RestController
@RequestMapping("/zdgz/psjc")
public class PsjcController extends BaseController
{
    @Autowired
    private IPsjcService psjcService;

    /**
     * 查询主排水测点基础数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Psjc psjc)
    {
        startPage();
        List<Psjc> list = psjcService.selectPsjcList(psjc);
        return getDataTable(list);
    }

    /**
     * 导出主排水测点基础数据列表
     */
    @Log(title = "主排水测点基础数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Psjc psjc)
    {
        List<Psjc> list = psjcService.selectPsjcList(psjc);
        ExcelUtil<Psjc> util = new ExcelUtil<Psjc>(Psjc.class);
        return util.exportExcel(list, "主排水测点基础数据数据");
    }

    /**
     * 获取主排水测点基础数据详细信息
     */
    @GetMapping(value = "/{cdbm}")
    public AjaxResult getInfo(@PathVariable("cdbm") String cdbm)
    {
        return AjaxResult.success(psjcService.selectPsjcById(cdbm));
    }

    /**
     * 新增主排水测点基础数据
     */
    @Log(title = "主排水测点基础数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Psjc psjc)
    {
        return toAjax(psjcService.insertPsjc(psjc));
    }

    /**
     * 修改主排水测点基础数据
     */
    @Log(title = "主排水测点基础数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Psjc psjc)
    {
        return toAjax(psjcService.updatePsjc(psjc));
    }

    /**
     * 删除主排水测点基础数据
     */
    @Log(title = "主排水测点基础数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cdbms}")
    public AjaxResult remove(@PathVariable String[] cdbms)
    {
        return toAjax(psjcService.deletePsjcByIds(cdbms));
    }
}
